/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cxhd.pacs.model;

import com.cxhd.pacs.tools.DateUtil;
import com.jfinal.plugin.activerecord.Model;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class CacheData extends Model<CacheData> {

    public static final CacheData dao = new CacheData();

    public void saveCache(String cacheName, String cacheValue, String hostId) {

        set("cacheName", cacheName)
                .set("cacheValue", cacheValue)
                .set("hostId", hostId)
                .set("createtime", DateUtil.getDateEN())
                .save();
        //return getInt("pk") + "";
    }

    public String getRptCache(String hostId,String cacheName) {
        try {
            return findFirst("select * from cachedata where hostId=? and cacheName=? and createtime >= DATE_SUB(CURDATE(),INTERVAL 1 DAY) ORDER BY createtime desc ", hostId,cacheName).getStr("cacheValue");
        } catch (Exception e) {
            return null;
        }

    }

}
